Currently, there are generally two instant messaging manners for a terminal: one is installing an instant messaging client on the terminal, and running the client to enter a dialog window; and the other is opening a webpage-version instant messaging page on a browser of the terminal, and performing online messaging on the current page of the browser. However, both the two messaging manners need to ensure that the dialog window is displayed on a foreground. For example, when a chat is performed by using the client, a chat window of the client needs to be kept on the foreground. If a user simultaneously opens the browser to browse a webpage, the user needs to switch between the client and the browser, and an operation is inconvenient. When the user performs a chat in a webpage manner on the browser, the current chat webpage needs to be kept on the top. When browsing another webpage, the user cannot check a message on the chat webpage in time.